﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace XUtliPoolLib
{
	// Token: 0x020001BC RID: 444
	public class XInterpolate
	{
		// Token: 0x060009FD RID: 2557 RVA: 0x00034650 File Offset: 0x00032850
		private static Vector3 Identity(Vector3 v)
		{
			return v;
		}

		// Token: 0x060009FE RID: 2558 RVA: 0x00034664 File Offset: 0x00032864
		private static Vector3 TransformDotPosition(Transform t)
		{
			return t.position;
		}

		// Token: 0x060009FF RID: 2559 RVA: 0x0003467C File Offset: 0x0003287C
		private static IEnumerable<float> NewTimer(float duration)
		{
			float elapsedTime = 0f;
			while (elapsedTime < duration)
			{
				yield return elapsedTime;
				elapsedTime += Time.deltaTime;
				if (elapsedTime >= duration)
				{
					yield return elapsedTime;
				}
			}
			yield break;
		}

		// Token: 0x06000A00 RID: 2560 RVA: 0x0003468C File Offset: 0x0003288C
		private static IEnumerable<float> NewCounter(int start, int end, int step)
		{
			for (int i = start; i <= end; i += step)
			{
				yield return (float)i;
			}
			yield break;
		}

		// Token: 0x06000A01 RID: 2561 RVA: 0x000346AC File Offset: 0x000328AC
		public static IEnumerator NewEase(XInterpolate.Function ease, Vector3 start, Vector3 end, float duration)
		{
			IEnumerable<float> driver = XInterpolate.NewTimer(duration);
			return XInterpolate.NewEase(ease, start, end, duration, driver);
		}

		// Token: 0x06000A02 RID: 2562 RVA: 0x000346D0 File Offset: 0x000328D0
		public static IEnumerator NewEase(XInterpolate.Function ease, Vector3 start, Vector3 end, int slices)
		{
			IEnumerable<float> driver = XInterpolate.NewCounter(0, slices + 1, 1);
			return XInterpolate.NewEase(ease, start, end, (float)(slices + 1), driver);
		}

		// Token: 0x06000A03 RID: 2563 RVA: 0x000346FA File Offset: 0x000328FA
		private static IEnumerator NewEase(XInterpolate.Function ease, Vector3 start, Vector3 end, float total, IEnumerable<float> driver)
		{
			Vector3 distance = end - start;
			foreach (float i in driver)
			{
				yield return XInterpolate.Ease(ease, start, distance, i, total);
			}
			//IEnumerator<float> enumerator = null;
			yield break;
			//yield break;
		}

		// Token: 0x06000A04 RID: 2564 RVA: 0x00034728 File Offset: 0x00032928
		private static Vector3 Ease(XInterpolate.Function ease, Vector3 start, Vector3 distance, float elapsedTime, float duration)
		{
			start.x = ease(start.x, distance.x, elapsedTime, duration);
			start.y = ease(start.y, distance.y, elapsedTime, duration);
			start.z = ease(start.z, distance.z, elapsedTime, duration);
			return start;
		}

		// Token: 0x06000A05 RID: 2565 RVA: 0x00034790 File Offset: 0x00032990
		public static XInterpolate.Function Ease(XInterpolate.EaseType type)
		{
			XInterpolate.Function result = null;
			switch (type)
			{
			case XInterpolate.EaseType.Linear:
				result = new XInterpolate.Function(XInterpolate.Linear);
				break;
			case XInterpolate.EaseType.EaseInQuad:
				result = new XInterpolate.Function(XInterpolate.EaseInQuad);
				break;
			case XInterpolate.EaseType.EaseOutQuad:
				result = new XInterpolate.Function(XInterpolate.EaseOutQuad);
				break;
			case XInterpolate.EaseType.EaseInOutQuad:
				result = new XInterpolate.Function(XInterpolate.EaseInOutQuad);
				break;
			case XInterpolate.EaseType.EaseInCubic:
				result = new XInterpolate.Function(XInterpolate.EaseInCubic);
				break;
			case XInterpolate.EaseType.EaseOutCubic:
				result = new XInterpolate.Function(XInterpolate.EaseOutCubic);
				break;
			case XInterpolate.EaseType.EaseInOutCubic:
				result = new XInterpolate.Function(XInterpolate.EaseInOutCubic);
				break;
			case XInterpolate.EaseType.EaseInQuart:
				result = new XInterpolate.Function(XInterpolate.EaseInQuart);
				break;
			case XInterpolate.EaseType.EaseOutQuart:
				result = new XInterpolate.Function(XInterpolate.EaseOutQuart);
				break;
			case XInterpolate.EaseType.EaseInOutQuart:
				result = new XInterpolate.Function(XInterpolate.EaseInOutQuart);
				break;
			case XInterpolate.EaseType.EaseInQuint:
				result = new XInterpolate.Function(XInterpolate.EaseInQuint);
				break;
			case XInterpolate.EaseType.EaseOutQuint:
				result = new XInterpolate.Function(XInterpolate.EaseOutQuint);
				break;
			case XInterpolate.EaseType.EaseInOutQuint:
				result = new XInterpolate.Function(XInterpolate.EaseInOutQuint);
				break;
			case XInterpolate.EaseType.EaseInSine:
				result = new XInterpolate.Function(XInterpolate.EaseInSine);
				break;
			case XInterpolate.EaseType.EaseOutSine:
				result = new XInterpolate.Function(XInterpolate.EaseOutSine);
				break;
			case XInterpolate.EaseType.EaseInOutSine:
				result = new XInterpolate.Function(XInterpolate.EaseInOutSine);
				break;
			case XInterpolate.EaseType.EaseInExpo:
				result = new XInterpolate.Function(XInterpolate.EaseInExpo);
				break;
			case XInterpolate.EaseType.EaseOutExpo:
				result = new XInterpolate.Function(XInterpolate.EaseOutExpo);
				break;
			case XInterpolate.EaseType.EaseInOutExpo:
				result = new XInterpolate.Function(XInterpolate.EaseInOutExpo);
				break;
			case XInterpolate.EaseType.EaseInCirc:
				result = new XInterpolate.Function(XInterpolate.EaseInCirc);
				break;
			case XInterpolate.EaseType.EaseOutCirc:
				result = new XInterpolate.Function(XInterpolate.EaseOutCirc);
				break;
			case XInterpolate.EaseType.EaseInOutCirc:
				result = new XInterpolate.Function(XInterpolate.EaseInOutCirc);
				break;
			}
			return result;
		}

		// Token: 0x06000A06 RID: 2566 RVA: 0x0003497C File Offset: 0x00032B7C
		public static IEnumerable<Vector3> NewBezier(XInterpolate.Function ease, Transform[] nodes, float duration)
		{
			IEnumerable<float> steps = XInterpolate.NewTimer(duration);
			return XInterpolate.NewBezier<Transform>(ease, nodes, new XInterpolate.ToVector3<Transform>(XInterpolate.TransformDotPosition), duration, steps);
		}

		// Token: 0x06000A07 RID: 2567 RVA: 0x000349AC File Offset: 0x00032BAC
		public static IEnumerable<Vector3> NewBezier(XInterpolate.Function ease, Transform[] nodes, int slices)
		{
			IEnumerable<float> steps = XInterpolate.NewCounter(0, slices + 1, 1);
			return XInterpolate.NewBezier<Transform>(ease, nodes, new XInterpolate.ToVector3<Transform>(XInterpolate.TransformDotPosition), (float)(slices + 1), steps);
		}

		// Token: 0x06000A08 RID: 2568 RVA: 0x000349E4 File Offset: 0x00032BE4
		public static IEnumerable<Vector3> NewBezier(XInterpolate.Function ease, Vector3[] points, float duration)
		{
			IEnumerable<float> steps = XInterpolate.NewTimer(duration);
			return XInterpolate.NewBezier<Vector3>(ease, points, new XInterpolate.ToVector3<Vector3>(XInterpolate.Identity), duration, steps);
		}

		// Token: 0x06000A09 RID: 2569 RVA: 0x00034A14 File Offset: 0x00032C14
		public static IEnumerable<Vector3> NewBezier(XInterpolate.Function ease, Vector3[] points, int slices)
		{
			IEnumerable<float> steps = XInterpolate.NewCounter(0, slices + 1, 1);
			return XInterpolate.NewBezier<Vector3>(ease, points, new XInterpolate.ToVector3<Vector3>(XInterpolate.Identity), (float)(slices + 1), steps);
		}

		// Token: 0x06000A0A RID: 2570 RVA: 0x00034A49 File Offset: 0x00032C49
		private static IEnumerable<Vector3> NewBezier<T>(XInterpolate.Function ease, IList nodes, XInterpolate.ToVector3<T> toVector3, float maxStep, IEnumerable<float> steps)
		{
			if (nodes.Count >= 2)
			{
				Vector3[] points = new Vector3[nodes.Count];
				foreach (float step in steps)
				{
					int num;
					for (int i = 0; i < nodes.Count; i = num + 1)
					{
						points[i] = toVector3((T)((object)nodes[i]));
						num = i;
					}
					yield return XInterpolate.Bezier(ease, points, step, maxStep);
				}
				//IEnumerator<float> enumerator = null;
				points = null;
			}
			yield break;
			//yield break;
		}

		// Token: 0x06000A0B RID: 2571 RVA: 0x00034A78 File Offset: 0x00032C78
		private static Vector3 Bezier(XInterpolate.Function ease, Vector3[] points, float elapsedTime, float duration)
		{
			for (int i = points.Length - 1; i > 0; i--)
			{
				for (int j = 0; j < i; j++)
				{
					points[j].x = ease(points[j].x, points[j + 1].x - points[j].x, elapsedTime, duration);
					points[j].y = ease(points[j].y, points[j + 1].y - points[j].y, elapsedTime, duration);
					points[j].z = ease(points[j].z, points[j + 1].z - points[j].z, elapsedTime, duration);
				}
			}
			return points[0];
		}

		// Token: 0x06000A0C RID: 2572 RVA: 0x00034B78 File Offset: 0x00032D78
		public static IEnumerable<Vector3> NewCatmullRom(Transform[] nodes, int slices, bool loop)
		{
			return XInterpolate.NewCatmullRom<Transform>(nodes, new XInterpolate.ToVector3<Transform>(XInterpolate.TransformDotPosition), slices, loop);
		}

		// Token: 0x06000A0D RID: 2573 RVA: 0x00034BA0 File Offset: 0x00032DA0
		public static IEnumerable<Vector3> NewCatmullRom(Vector3[] points, int slices, bool loop)
		{
			return XInterpolate.NewCatmullRom<Vector3>(points, new XInterpolate.ToVector3<Vector3>(XInterpolate.Identity), slices, loop);
		}

		// Token: 0x06000A0E RID: 2574 RVA: 0x00034BC6 File Offset: 0x00032DC6
		private static IEnumerable<Vector3> NewCatmullRom<T>(IList nodes, XInterpolate.ToVector3<T> toVector3, int slices, bool loop)
		{
			if (nodes.Count >= 2)
			{
				yield return toVector3((T)((object)nodes[0]));
				int last = nodes.Count - 1;
				int current = 0;
				while (loop || current < last)
				{
					if (loop && current > last)
					{
						current = 0;
					}
					int previous = (current == 0) ? (loop ? last : current) : (current - 1);
					int start = current;
					int end = (current == last) ? (loop ? 0 : current) : (current + 1);
					int next = (end == last) ? (loop ? 0 : end) : (end + 1);
					int stepCount = slices + 1;
					int num;
					for (int step = 1; step <= stepCount; step = num + 1)
					{
						yield return XInterpolate.CatmullRom(toVector3((T)((object)nodes[previous])), toVector3((T)((object)nodes[start])), toVector3((T)((object)nodes[end])), toVector3((T)((object)nodes[next])), (float)step, (float)stepCount);
						num = step;
					}
					num = current;
					current = num + 1;
				}
			}
			yield break;
		}

		// Token: 0x06000A0F RID: 2575 RVA: 0x00034BEC File Offset: 0x00032DEC
		private static Vector3 CatmullRom(Vector3 previous, Vector3 start, Vector3 end, Vector3 next, float elapsedTime, float duration)
		{
			float num = elapsedTime / duration;
			float num2 = num * num;
			float num3 = num2 * num;
			return previous * (-0.5f * num3 + num2 - 0.5f * num) + start * (1.5f * num3 + -2.5f * num2 + 1f) + end * (-1.5f * num3 + 2f * num2 + 0.5f * num) + next * (0.5f * num3 - 0.5f * num2);
		}

		// Token: 0x06000A10 RID: 2576 RVA: 0x00034C80 File Offset: 0x00032E80
		private static float Linear(float start, float distance, float elapsedTime, float duration)
		{
			if (elapsedTime > duration)
			{
				elapsedTime = duration;
			}
			return distance * (elapsedTime / duration) + start;
		}

		// Token: 0x06000A11 RID: 2577 RVA: 0x00034CA8 File Offset: 0x00032EA8
		private static float EaseInQuad(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 1f : (elapsedTime / duration));
			return distance * elapsedTime * elapsedTime + start;
		}

		// Token: 0x06000A12 RID: 2578 RVA: 0x00034CD4 File Offset: 0x00032ED4
		private static float EaseOutQuad(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 1f : (elapsedTime / duration));
			return -distance * elapsedTime * (elapsedTime - 2f) + start;
		}

		// Token: 0x06000A13 RID: 2579 RVA: 0x00034D04 File Offset: 0x00032F04
		private static float EaseInOutQuad(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 2f : (elapsedTime / (duration / 2f)));
			float result;
			if (elapsedTime < 1f)
			{
				result = distance / 2f * elapsedTime * elapsedTime + start;
			}
			else
			{
				elapsedTime -= 1f;
				result = -distance / 2f * (elapsedTime * (elapsedTime - 2f) - 1f) + start;
			}
			return result;
		}

		// Token: 0x06000A14 RID: 2580 RVA: 0x00034D6C File Offset: 0x00032F6C
		private static float EaseInCubic(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 1f : (elapsedTime / duration));
			return distance * elapsedTime * elapsedTime * elapsedTime + start;
		}

		// Token: 0x06000A15 RID: 2581 RVA: 0x00034D98 File Offset: 0x00032F98
		private static float EaseOutCubic(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 1f : (elapsedTime / duration));
			elapsedTime -= 1f;
			return distance * (elapsedTime * elapsedTime * elapsedTime + 1f) + start;
		}

		// Token: 0x06000A16 RID: 2582 RVA: 0x00034DD4 File Offset: 0x00032FD4
		private static float EaseInOutCubic(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 2f : (elapsedTime / (duration / 2f)));
			float result;
			if (elapsedTime < 1f)
			{
				result = distance / 2f * elapsedTime * elapsedTime * elapsedTime + start;
			}
			else
			{
				elapsedTime -= 2f;
				result = distance / 2f * (elapsedTime * elapsedTime * elapsedTime + 2f) + start;
			}
			return result;
		}

		// Token: 0x06000A17 RID: 2583 RVA: 0x00034E38 File Offset: 0x00033038
		private static float EaseInQuart(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 1f : (elapsedTime / duration));
			return distance * elapsedTime * elapsedTime * elapsedTime * elapsedTime + start;
		}

		// Token: 0x06000A18 RID: 2584 RVA: 0x00034E68 File Offset: 0x00033068
		private static float EaseOutQuart(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 1f : (elapsedTime / duration));
			elapsedTime -= 1f;
			return -distance * (elapsedTime * elapsedTime * elapsedTime * elapsedTime - 1f) + start;
		}

		// Token: 0x06000A19 RID: 2585 RVA: 0x00034EA8 File Offset: 0x000330A8
		private static float EaseInOutQuart(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 2f : (elapsedTime / (duration / 2f)));
			float result;
			if (elapsedTime < 1f)
			{
				result = distance / 2f * elapsedTime * elapsedTime * elapsedTime * elapsedTime + start;
			}
			else
			{
				elapsedTime -= 2f;
				result = -distance / 2f * (elapsedTime * elapsedTime * elapsedTime * elapsedTime - 2f) + start;
			}
			return result;
		}

		// Token: 0x06000A1A RID: 2586 RVA: 0x00034F14 File Offset: 0x00033114
		private static float EaseInQuint(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 1f : (elapsedTime / duration));
			return distance * elapsedTime * elapsedTime * elapsedTime * elapsedTime * elapsedTime + start;
		}

		// Token: 0x06000A1B RID: 2587 RVA: 0x00034F44 File Offset: 0x00033144
		private static float EaseOutQuint(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 1f : (elapsedTime / duration));
			elapsedTime -= 1f;
			return distance * (elapsedTime * elapsedTime * elapsedTime * elapsedTime * elapsedTime + 1f) + start;
		}

		// Token: 0x06000A1C RID: 2588 RVA: 0x00034F84 File Offset: 0x00033184
		private static float EaseInOutQuint(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 2f : (elapsedTime / (duration / 2f)));
			float result;
			if (elapsedTime < 1f)
			{
				result = distance / 2f * elapsedTime * elapsedTime * elapsedTime * elapsedTime * elapsedTime + start;
			}
			else
			{
				elapsedTime -= 2f;
				result = distance / 2f * (elapsedTime * elapsedTime * elapsedTime * elapsedTime * elapsedTime + 2f) + start;
			}
			return result;
		}

		// Token: 0x06000A1D RID: 2589 RVA: 0x00034FF0 File Offset: 0x000331F0
		private static float EaseInSine(float start, float distance, float elapsedTime, float duration)
		{
			if (elapsedTime > duration)
			{
				elapsedTime = duration;
			}
			return -distance * Mathf.Cos(elapsedTime / duration * 1.5707964f) + distance + start;
		}

		// Token: 0x06000A1E RID: 2590 RVA: 0x00035024 File Offset: 0x00033224
		private static float EaseOutSine(float start, float distance, float elapsedTime, float duration)
		{
			if (elapsedTime > duration)
			{
				elapsedTime = duration;
			}
			return distance * Mathf.Sin(elapsedTime / duration * 1.5707964f) + start;
		}

		// Token: 0x06000A1F RID: 2591 RVA: 0x00035058 File Offset: 0x00033258
		private static float EaseInOutSine(float start, float distance, float elapsedTime, float duration)
		{
			if (elapsedTime > duration)
			{
				elapsedTime = duration;
			}
			return -distance / 2f * (Mathf.Cos(3.1415927f * elapsedTime / duration) - 1f) + start;
		}

		// Token: 0x06000A20 RID: 2592 RVA: 0x00035098 File Offset: 0x00033298
		private static float EaseInExpo(float start, float distance, float elapsedTime, float duration)
		{
			if (elapsedTime > duration)
			{
				elapsedTime = duration;
			}
			return distance * Mathf.Pow(2f, 10f * (elapsedTime / duration - 1f)) + start;
		}

		// Token: 0x06000A21 RID: 2593 RVA: 0x000350D4 File Offset: 0x000332D4
		private static float EaseOutExpo(float start, float distance, float elapsedTime, float duration)
		{
			if (elapsedTime > duration)
			{
				elapsedTime = duration;
			}
			return distance * (-Mathf.Pow(2f, -10f * elapsedTime / duration) + 1f) + start;
		}

		// Token: 0x06000A22 RID: 2594 RVA: 0x00035114 File Offset: 0x00033314
		private static float EaseInOutExpo(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 2f : (elapsedTime / (duration / 2f)));
			float result;
			if (elapsedTime < 1f)
			{
				result = distance / 2f * Mathf.Pow(2f, 10f * (elapsedTime - 1f)) + start;
			}
			else
			{
				elapsedTime -= 1f;
				result = distance / 2f * (-Mathf.Pow(2f, -10f * elapsedTime) + 2f) + start;
			}
			return result;
		}

		// Token: 0x06000A23 RID: 2595 RVA: 0x00035198 File Offset: 0x00033398
		private static float EaseInCirc(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 1f : (elapsedTime / duration));
			return -distance * (Mathf.Sqrt(1f - elapsedTime * elapsedTime) - 1f) + start;
		}

		// Token: 0x06000A24 RID: 2596 RVA: 0x000351D4 File Offset: 0x000333D4
		private static float EaseOutCirc(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 1f : (elapsedTime / duration));
			elapsedTime -= 1f;
			return distance * Mathf.Sqrt(1f - elapsedTime * elapsedTime) + start;
		}

		// Token: 0x06000A25 RID: 2597 RVA: 0x00035214 File Offset: 0x00033414
		private static float EaseInOutCirc(float start, float distance, float elapsedTime, float duration)
		{
			elapsedTime = ((elapsedTime > duration) ? 2f : (elapsedTime / (duration / 2f)));
			float result;
			if (elapsedTime < 1f)
			{
				result = -distance / 2f * (Mathf.Sqrt(1f - elapsedTime * elapsedTime) - 1f) + start;
			}
			else
			{
				elapsedTime -= 2f;
				result = distance / 2f * (Mathf.Sqrt(1f - elapsedTime * elapsedTime) + 1f) + start;
			}
			return result;
		}

		// Token: 0x02000397 RID: 919
		public enum EaseType
		{
			// Token: 0x04000FE5 RID: 4069
			Linear,
			// Token: 0x04000FE6 RID: 4070
			EaseInQuad,
			// Token: 0x04000FE7 RID: 4071
			EaseOutQuad,
			// Token: 0x04000FE8 RID: 4072
			EaseInOutQuad,
			// Token: 0x04000FE9 RID: 4073
			EaseInCubic,
			// Token: 0x04000FEA RID: 4074
			EaseOutCubic,
			// Token: 0x04000FEB RID: 4075
			EaseInOutCubic,
			// Token: 0x04000FEC RID: 4076
			EaseInQuart,
			// Token: 0x04000FED RID: 4077
			EaseOutQuart,
			// Token: 0x04000FEE RID: 4078
			EaseInOutQuart,
			// Token: 0x04000FEF RID: 4079
			EaseInQuint,
			// Token: 0x04000FF0 RID: 4080
			EaseOutQuint,
			// Token: 0x04000FF1 RID: 4081
			EaseInOutQuint,
			// Token: 0x04000FF2 RID: 4082
			EaseInSine,
			// Token: 0x04000FF3 RID: 4083
			EaseOutSine,
			// Token: 0x04000FF4 RID: 4084
			EaseInOutSine,
			// Token: 0x04000FF5 RID: 4085
			EaseInExpo,
			// Token: 0x04000FF6 RID: 4086
			EaseOutExpo,
			// Token: 0x04000FF7 RID: 4087
			EaseInOutExpo,
			// Token: 0x04000FF8 RID: 4088
			EaseInCirc,
			// Token: 0x04000FF9 RID: 4089
			EaseOutCirc,
			// Token: 0x04000FFA RID: 4090
			EaseInOutCirc
		}

		// Token: 0x02000398 RID: 920
		// (Invoke) Token: 0x06000F30 RID: 3888
		public delegate Vector3 ToVector3<T>(T v);

		// Token: 0x02000399 RID: 921
		// (Invoke) Token: 0x06000F34 RID: 3892
		public delegate float Function(float a, float b, float c, float d);
	}
}
